const express=require('express')

const app=express()
const fs=require('fs')
const {data}=require('./mock/index')
app.use(express.static('../list'))

app.get('/api/list',(req,res)=>{
    res.send({
        code:200,
        data
    })
})
app.get('/detail',(req,res)=>{
    res.end(fs.readFileSync('../list/detail.html'))
})
app.get('/api/getDetail',(req,res)=>{
    const {id}=req.query
    res.send({
        code:200,
        data:data.find(item=>item.id===id)
    })
})
app.listen(8080)



